﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace GMAC.ReportingSystem
{
    public partial class MenuTemplate : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!this.IsPostBack)
            {
                Business.Entities.User user = Session["User"] as Business.Entities.User;
                if (user != null)
                {
                    if (user.Role.Security == null)
                    {
                        Business.Components.RoleComponent rbc = new GMAC.ReportingSystem.Business.Components.RoleComponent();
                        user.Role = rbc.GetDetails(user.Role.RoleID);
                    }
                    this.Accordion1.DataSource = user.Role.Security.Menus;
                    this.Accordion1.DataBind();
                }
            }
        }

        protected void lnkExit_Click(object sender, EventArgs e)
        {
            Session.Clear();
            Session.Abandon();
            FormsAuthentication.SignOut();
            FormsAuthentication.RedirectToLoginPage();
        }
    }
}
